<template>
  <el-dialog
    title="修改追踪号"
    :modal="false"
    :visible.sync="centerDialogVisible"
    width="50%"
    center
  >
    <div>
      <el-row :gutter="6">
        <el-form
          ref="paramForm"
          :model="paramData"
          size="mini"
          label-width="280px"
        >
          <el-row>
            <el-col :span="14">
              <el-form-item label="跟踪号1" prop="trackNumber">
                <el-input
                  v-model="paramData.trackNumber"
                  placeholder="请输入跟踪号1"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="14">
              <el-form-item label="追踪号1类型" prop="track1Type">
                <el-select
                  v-model="paramData.track1Type"
                  placeholder="请输入追踪号1类型"
                  clearable
                  filterable
                  :style="{ width: '100%' }"
                >
                  <el-option
                    v-for="(k, v) in accountTypeOptions"
                    :key="k"
                    :label="accountTypeOptions[v]"
                    :value="v"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="14">
              <el-form-item label="跟踪号2" prop="trackNumber2">
                <el-input
                  v-model="paramData.trackNumber2"
                  placeholder="请输跟踪号2"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="14">
              <el-form-item label="追踪号2类型" prop="track2Type">
                <el-select
                  v-model="paramData.track2Type"
                  placeholder="请输入追踪号2类型"
                  clearable
                  filterable
                  :style="{ width: '100%' }"
                >
                  <el-option
                    v-for="(k, v) in accountTypeOptions"
                    :key="k"
                    :label="accountTypeOptions[v]"
                    :value="v"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="14">
              <el-form-item label="跟踪号3" prop="trackNumber3">
                <el-input
                  v-model="paramData.trackNumber3"
                  placeholder="请输入跟踪号3"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="14">
              <el-form-item label="追踪号3类型" prop="track3Type">
                <el-select
                  v-model="paramData.track3Type"
                  placeholder="请输入追踪号3类型"
                  clearable
                  filterable
                  :style="{ width: '100%' }"
                >
                  <el-option
                    v-for="(k, v) in accountTypeOptions"
                    :key="k"
                    :label="accountTypeOptions[v]"
                    :value="v"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-row>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="centerDialogVisible = false">取 消</el-button>
      <el-button
        type="primary"
        @click="editTrackNo"
        v-loading.fullscreen.lock="fullscreenLoading"
        >确 定</el-button
      >
    </span>
  </el-dialog>
</template>

<script>
import { ajax } from "@/store/yg/common/utils";
import axios from "axios";
import * as constant from "@/store/yg/common/constant";
import { m } from "@/store/yg/common/local";
export default {
  props: ["row", "data", "more"],
  data() {
    return {
      fullscreenLoading: false,
      centerDialogVisible: false,
      paramData: {
        id: 0,
        trackNumber: "",
        track1Type: "",
        trackNumber2: "",
        track2Type: "",
        trackNumber3: "",
        track3Type: ""
      },
      accountTypeOptions: {
        UPS: "UPS",
        FEDEX: "FEDEX",
        DPDUK1: "DPDUK1",
        DPD1: "DPD1",
        DPDUK2: "DPDUK2",
        DPD2: "DPD2",
        DHL: "DHL",
        TNT: "TNT",
        CHROPOST: "CHROPOST",
        DHLGERMANY: "DHLGERMANY",
        DHLTRUCKNL: "DHLTRUCKNL",
        BONDED: "BONDED",
        DHLDE: "DHLDE",
        BRT: "BRT",
        GreenBox: "GreenBox",
        JAPANLINE: "JAPANLINE",
        FBCTRUCKDELIVERY: "FBCTRUCKDELIVERY",
        GLS: "GLS",
        "DPD(DE)": "DPD(DE)"
      }
    };
  },

  methods: {
    //修改派送仓库地址
    editTrackNo() {
      var param = {};
      param["id"] = this.data["id"];
      param["fba"] = 0;
      param["trackNumber"] = this.paramData.trackNumber;
      param["track1Type"] = this.paramData.track1Type;
      param["trackNumber2"] = this.paramData.trackNumber2;
      param["track2Type"] = this.paramData.track2Type;
      param["trackNumber3"] = this.paramData.trackNumber3;
      param["track3Type"] = this.paramData.track3Type;
      console.log("param:", param);
      this.fullscreenLoading = true;
      ajax("editTrackNo", param).then(
        res => {
          this.fullscreenLoading = false;
          if (res.code != 200) {
            if (null != res.message) {
              this.$message.error(m(res.message));
            } else {
              this.$message.error("修改失败!");
            }
          } else {
            this.$message.success("修改成功!");
            this.centerDialogVisible = false;
            location.reload();
          }
        },
        error => {
          console.log(error);
        }
      );
    }
  },
  mounted() {
    this.paramData.trackNumber = this.data["trackNumber"];
    this.paramData.track1Type = this.data["track1Type"];
    this.paramData.trackNumber2 = this.data["trackNumber2"];
    this.paramData.track2Type = this.data["track2Type"];
    this.paramData.trackNumber3 = this.data["trackNumber3"];
    this.paramData.track3Type = this.data["track3Type"];
  }
};
</script>

<style></style>
